Mersenne Twister Random Number Generator

The Mersenne Twister is an algorithm for generating random numbers. It was designed with consideration of the flaws in various other generators. The period, 2^19937-1, and the order of equidistribution, 623 dimensions, are far greater. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. See the inventors' page for more details.

I have implemented the Mersenne Twister in a C++ class that is fast, convenient, portable, and free. Take a look at the class or download the complete package in zip or tarball format. The latest version, v0.8, corrects the list of included headers.

Features:

On my system, a Pentium III running Linux at 500 MHz, the performance test gives the following results for generation of random integers:

MersenneTwister.h17.8 million per second
Original C version10.8 million per second
Cokus's optimized C version11.8 million per second
Standard rand()5.8 million per second

^ home
Rick Wagner ( rjwagner@writeme.com ) 24 Mar 02